package com.demo.dubbo;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author 许路路
 */
public class MyInvocationHandler implements InvocationHandler {

    private Object target;

    public MyInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("调用方法:" + method.getName());
        //对回声测试的方法直接返回
        if ("$hello".equals(method.getName())) {
            return args[0];
        }
        return method.invoke(target, args);
    }
}
